package com.apex.shared.mybatis.config;

import com.apex.shared.redis.utils.RedissonUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * Apex TenantContextHolder
 *
 * @author Bangda Xiao
 */
@Component
public class TenantContextHolder {

    @Resource
    RedissonUtil redissonUtil;

    private static final String CURRENT_TENANT_ID = "CURRENT_TENANT_ID";

    /**
     * 获取租户ID
     * @param tenantId
     */
    public void setCurrentTenantId(String tenantId) {
        redissonUtil.set(CURRENT_TENANT_ID, tenantId);
    }

    /**
     * 返回租户ID
     * @return
     */
    public String getCurrentTenantId() {
        return redissonUtil.get(CURRENT_TENANT_ID);
    }
}
